import request from '@/utils/request'

/**
 * 获取订单统计数
 */
export function getHeadCountApi(type) {
  return request({
    url: `/api/Orders/Chart/${type}`,
    method: 'GET',
    headers: {
      isToken: true
    }
  })
}

/**
 * 获取所有订单信息
 * @param params 数据
 */
export function getOrderList(params) {
  return request({
    url: '/api/Orders',
    method: 'GET',
    params: Object.assign(params, { isGet: true })
  });
};

/**
 * 订单发货接口
 * @param id 编号
 * @param data
 * @returns {AxiosPromise}
 */
export function putOrderSendApi(id, data) {
  return request({
    url: `/api/Orders/Send/${id}`,
    method: 'PUT',
    headers: {
      isToken: true
    },
    data
  })
}

/**
 * 确认收货按钮
 * @param id  ID
 * @returns {AxiosPromise}
 */
export function getReceivingApi(id) {
  return request({
    url: `/api/Orders/Sign/${id}`,
    method: 'PUT'
  });
};

/**
 * 获取所有退款订单
 * @param params
 */
export function getOrderRefundList(params) {
  return request({
    url: '/api/Orders/Refunds',
    method: 'GET',
    params: Object.assign(params, { isGet: true })
  });
};

/**
 * 获取指定的订单
 * @param orderId
 * @returns {AxiosPromise}
 */
export function orderDetailApi(orderId) {
  return request({
    url: `/api/Orders/${orderId}`,
    method: 'GET'
  })
}

/**
 * 修改支付金额
 * @param data 数据
 * @returns {AxiosPromise}
 */
export function putOrderPayPriceApi(data) {
  const { id, payPrice } = data;
  return request({
    url: `/api/orders/payPrice/${id}`,
    method: 'PUT',
    data: {
      payPrice
    }
  })
}

/**
 * 获取指定的记录数
 * @param orderId
 * @returns {AxiosPromise}
 */
export function getOrderLogApi(orderId, params) {
  return request({
    url: `api/Orders/Records/${orderId}`,
    method: 'GET',
    params
  })
}

/**
 * 拒绝退款
 * @param data 数据
 * @returns {AxiosPromise}
 */
export function getRefuseRefund(orderId, data) {
  return request({
    url: `/api/Orders/Refunds/Refuse/${orderId}`,
    method: 'PUT',
    data
  });
};

/**
 * 立即退款处理
 * @param id ID
 * @returns {AxiosPromise}
 */
export function getRefundApi(id) {
  return request({
    url: `/api/Orders/Refunds/${id}`,
    method: 'PUT'
  });
};

/**
 * 退货退款
 * @param id ID
 * @returns {AxiosPromise}
 */
export function getReturnRefund(id) {
  return request({
    url: `/api/Orders/Refunds/Agree/${id}`,
    method: 'PUT'
  });
};
